package com.css.fxfzysx.constants;

import com.css.fxfzysx.base.exception.ParamException;
import com.css.fxfzysx.util.PlatformObjectUtils;

import java.util.TreeMap;

public enum Src3Enum {
    //整数的对应
    M10("M10", 0),

    M7("M7.5" , 1),

    M5("M5", 2),


    M2("M2.5", 3),

    M1("M1", 4),

    M0("M0.4", 5),


    GROUP1("第一组",0),

    GROUP2("第二组",1),

    GROUP3("第三组",2),

    //{"I0","I1","II","Ⅲ","Ⅳ"};
    SC1("Ⅰ0",0),

    SC2("Ⅰ1",1),

    SC3("Ⅱ",2),

    SC4("Ⅲ",3),

    SC5("Ⅳ",4),

    B1("普通砖、多孔砖", 1),

    B2("粉煤灰中砌块" , 2),

    B3("混凝土中砌块", 3),


    B4("混凝土小砌块", 4),

    B5("其他", 1);


    private   String code;

    private   int index;



    Src3Enum(String code,int index) {
        this.index = index;
        this.code = code;
    }

    private static final TreeMap<String, Src3Enum> M_SRC_ENUM_TREE_MAP = new TreeMap<>();


    static {
        for (Src3Enum src3Enum : Src3Enum.values()) {
            M_SRC_ENUM_TREE_MAP.put(src3Enum.code, src3Enum);
        }
    }

    public static Integer  getBycode(String code){
        if(PlatformObjectUtils.isEmpty(M_SRC_ENUM_TREE_MAP.get(code))){
            throw new ParamException("所选参数未在定义范围内，请联系管理员！");
        }
        return M_SRC_ENUM_TREE_MAP.get(code).getIndex();
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getCode() {
        return code;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}
